<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'order-info', //页面标示
    'pagename' => '借贷详情', //当前页面名称
    'mycss'    => array('content/order_table'), //加载的css样式表
    'myjs'     => array(), //加载的js脚本
    'footerjs' => array('content/highcharts', 'content/exporting', 'content/jquery.smoothConfirm'),
    'head'     => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<style>.pt7{padding-top:7px;}</style>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <!-- main padder --> 
    <section id="content"> 
   <section class="main padder"> 
    <div class="clearfix"> 
     <h4><i class="fa fa-edit"></i>借贷详情</h4> 
    </div> 
    <div class="row"> 
     <div class="col-sm-12"> 
      <section class="panel"> 
       <div class="panel-body"> 
        <form class="form-horizontal" method="get" data-validate="parsley"> 
         <div class="form-group"> 
          <label class="col-sm-2 control-label">借贷编号</label> 
          <div class="col-sm-5 pt7"> 
          	<?php echo $info['order_sn'];?>
          	<div class="line line-dashed m-t-large"></div> 
          </div> 
         </div>

         <div class="form-group"> 
          <label class="col-sm-2 control-label">状态</label> 
          <div class="col-sm-5 pt7"> 
          	<?php echo $orderStateArry[$info['order_state']];?>
          	<div class="line line-dashed m-t-large"></div> 
          </div> 
         </div>
         <?php if($info['order_state'] == 62 && $diff_days && $over_interest){ ?>
          <div class="form-group"> 
            <label class="col-sm-2 control-label">已超出逾期</label> 
            <div class="col-sm-5 pt7">
              <span class="red"><?php echo $diff_days; ?> 天</span>
              <div class="line line-dashed m-t-large"></div> 
            </div> 
          </div>
          <div class="form-group"> 
            <label class="col-sm-2 control-label">逾期利息</label> 
            <div class="col-sm-5 pt7">
              <span class="red"><?php echo $over_interest ?>.00</span>
              <div class="line line-dashed m-t-large"></div> 
            </div> 
          </div>

         <?php } ?>
          <?php if($info['reason']){  ?>
           <div class="form-group"> 
            <label class="col-sm-2 control-label">还款失败原因</label> 
            <div class="col-sm-5 pt7">
              <span class="clrb"><?php echo $info['reason']; ?></span>
              <div class="line line-dashed m-t-large"></div> 
            </div> 
           </div>  
         <?php } ?>

         <?php if($info['refund_time']){ ?>
            <div class="form-group"> 
                <label class="col-sm-2 control-label">申请全额还款时间</label> 
                <div class="col-sm-5 pt7"> 
                  <?php echo outTime($info['refund_time']);?>
                  <div class="line line-dashed m-t-large"></div> 
                </div> 
             </div>

             <div class="form-group"> 
                <label class="col-sm-2 control-label">申请全额还款金额</label> 
                <div class="col-sm-5 pt7"> 
                  <span class="red"><?php echo $info['refund_amount'];?></span>
                  <div class="line line-dashed m-t-large"></div> 
                </div> 
             </div>
         <?php } ?> 



         <?php if($info['cancel_time']){  ?>
           <div class="form-group"> 
            <label class="col-sm-2 control-label">取消时间</label> 
            <div class="col-sm-5 pt7">
              <?php echo date('Y-m-d H:i:s', $info['cancel_time']); ?>
              <div class="line line-dashed m-t-large"></div> 
            </div> 
           </div>  
         <?php } ?>
         <?php if($info['order_state'] == 0){ ?>
            <div class="form-group"> 
                <label class="col-sm-2 control-label">取消原因</label> 
                <div class="col-sm-5 pt7"> 
                  <span class="red"><?php echo $info['remark'];?></span>
                  <div class="line line-dashed m-t-large"></div> 
                </div> 
             </div>
         <?php } ?> 

         <?php if($info['person_iou_img']) { ?>
            <div class="form-group"> 
                <label class="col-sm-2 control-label">借款人手持借条</label> 
                <div class="col-sm-5 pt7"> 
                  <a rel="pop" href="<?php echo getImgUrl($info['person_iou_img']) ?>">预览 >></a> 
                  <div class="line line-dashed m-t-large"></div> 
                </div> 
             </div>
         <?php } ?>

         <div class="form-group"> 
          <label class="col-sm-2 control-label">借款金额</label> 
          <div class="col-sm-5 pt7"> 
          	<?php echo $info['amount'];?>
          	<div class="line line-dashed m-t-large"></div> 
          </div> 
         </div> 

         <div class="form-group"> 
          <label class="col-sm-2 control-label">实借金额</label> 
          <div class="col-sm-5 pt7"> 
            <?php echo $info['actual_amount'];?>
            <div class="line line-dashed m-t-large"></div> 
          </div> 
         </div>

         <div class="form-group"> 
          <label class="col-sm-2 control-label">手续费</label> 
          <div class="col-sm-5 pt7"> 
            <?php echo $info['counter_fee'];?>
            <div class="line line-dashed m-t-large"></div> 
          </div> 
         </div>

         <div class="form-group"> 
          <label class="col-sm-2 control-label">借款人</label> 
          <div class="col-sm-5 pt7"> 
          	<a rel="pop" href="<?php echo U('member/detail',array('uid'=>$info['user_id'])) ?>" title="点击查看会员信息"><?php echo $info['name'];?></a>
          	<div class="line line-dashed m-t-large"></div> 
          </div> 
         </div> 

         <div class="form-group"> 
          <label class="col-sm-2 control-label">联系电话</label> 
          <div class="col-sm-5 pt7"> 
          	<?php echo $info['phone'];?>
          	<div class="line line-dashed m-t-large"></div> 
          </div> 
         </div> 

         <div class="form-group"> 
          <label class="col-sm-2 control-label">借款类别</label> 
          <div class="col-sm-5 pt7"> 
          	<?php echo $info['order_type'] == 10 ? '【学生借】' : '【社会借】';?>
          	<div class="line line-dashed m-t-large"></div> 
          </div> 
         </div> 

         <div class="form-group"> 
          <label class="col-sm-2 control-label">申请时间</label> 
          <div class="col-sm-5 pt7"> 
          	<?php if($info['create_time']) echo outTime($info['create_time']); ?>
          	<div class="line line-dashed m-t-large"></div> 
          </div>
         </div> 
         <?php if($info['confirm_time']){  ?>
             <div class="form-group"> 
              <label class="col-sm-2 control-label">确认时间</label> 
              <div class="col-sm-5 pt7"> 
              	<?php  echo date('Y-m-d H:i:s', $info['confirm_time']); ?>
              	<div class="line line-dashed m-t-large"></div> 
              </div> 
             </div> 
         <?php } ?>
         <?php if($info['due_time']){  ?>
         <div class="form-group"> 
          <label class="col-sm-2 control-label">还款到期日</label> 
          <div class="col-sm-5 pt7"> 
          	<?php  echo date('Y-m-d H:i:s', $info['due_time']); ?>
          	<div class="line line-dashed m-t-large"></div> 
          </div> 
         </div> 
         <?php } ?>
         <?php if($info['finish_time']){  ?>
        <div class="form-group"> 
          <label class="col-sm-2 control-label">借款完成时间</label> 
          <div class="col-sm-5 pt7">
            <?php  echo date('Y-m-d H:i:s', $info['finish_time']); ?>
            <div class="line line-dashed m-t-large"></div> 
          </div> 
         </div>
         <?php } ?>
        <?php if($operate_btn){  ?>
        <div class="form-group"> 
          <label class="col-sm-2 control-label">可执行操作</label> 
          <div class="col-sm-5 pt7">
            <?php echo $operate_btn; ?>
            <div class="line line-dashed m-t-large"></div> 
          </div> 
         </div> 
         <?php } ?>
      <?php if($data_list){  ?>   
		 	<section class="panel"> 
		        <header class="panel-heading">
		         <b>【 利息还款 】</b> 
		         <i class="fa fa-info-sign text-muted" data-toggle="popover" data-html="true" data-placement="top" data-content="The datatables use ajax to load the data. please put this file on a server to preview." title="" data-trigger="hover" data-original-title="Help"></i> 
		        </header> 
		        <div class="table-responsive"> 
		         <table class="table table-striped m-b-none" data-ride="datatables"> 
		          <thead> 
		           <tr> 
		            <th>期数</th> 
		            <th>还款金额(RMB)</th>
                <th>还款日期(往后推3日)</th> 
		            <th>状态</th>
                <th>操作</th> 
		           </tr> 
		          </thead> 
		          <tbody> 
		          <?php foreach ($data_list as $key => $value) { ?>
		          <tr>
		          	<td align="center">【 <?php echo $value['number']; ?> 】</td>
		          	<td align="center"><span class="bule"><?php echo $value['payment']; ?></span></td>
                <td align="center"><span class="clra"><?php echo outTime($value['node_time'] , 2) ?></span></td>
		          	<td align="center" id="set_user_id_<?php echo $value['id'] ?>"><?php echo $lxStatusArray[$value['status']]; ?></td>
		          	<td align="center">
                  <?php if(($value['status'] == 3 || $value['status'] == 5) && admin::$adminInfo['groupid'] == 1){ ?>
                    <a href="javascript:;" onclick="changeFirstState(this);" data-id="<?php echo $value['id'] ?>">管理审核</a>
                  <?php }else if($value['status'] == 10 && admin::$adminInfo['groupid'] == 2){ ?>
                    <a href="javascript:;" onclick="changeSecondState(this);" data-id="<?php echo $value['id'] ?>" <?php if($key == 9){ ?>is-last = 1<?php } ?> >财务审核</a>
                  <?php } ?>  
                </td>
		          </tr>
		          <?php } ?>
		          </tbody> 
		         </table> 
		        </div> 
		       </section>
		      <?php } ?>
         </div> 
        </form> 
       </div> 
      </section>
     </div> 
    </div> 
   </section> 
  </section> 

    <!--/ main padder -->  
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
function confirmForm(orderid , status) {
    $(".return_btn").smoothConfirm("确认执行该操作吗？", {
      ok: function() {
          $.post('<?php echo U('order/change_order_status');?>',{"id":orderid , "status":status},function(result){
               if(result.status){
                  window.location.reload();
               }else{
                  Msg.error(result.info);
                  return false;
               }
          },'json');
      },
      cancel: function() {
        return false;
      }
    });
}

function changeFirstState(obj) {
  var id=$(obj).attr('data-id');
  $(obj).smoothConfirm("请选择操作类型", {
      okVal:'通过',
      cancelVal:'失败',
      ok: function() {
        Msg.loading();
        $.post('<?php echo U('order/changeInterestStatus');?>',{"id":id,"status":10},function(result){
          Msg.hide();
          $("#set_user_id_"+id).html("<?php echo $lxStatusArray[10];?>");
          $(obj).hide();
        },'json');
      },
      cancel: function() {
          $.post('<?php echo U('order/changeInterestStatus');?>',{"id":id,"status":5},function(result){
            Msg.hide();
            $("#set_user_id_"+id).html("<?php echo $lxStatusArray[5];?>");
          },'json');
      }
    });
}

function changeSecondState(obj) {
  var id=$(obj).attr('data-id');
  var islast = $(obj).attr('is-last');
    $(obj).smoothConfirm("请选择操作类型", {
      okVal:'通过',
      cancelVal:'失败',
      ok: function() {
        Msg.loading();
        $.post('<?php echo U('order/changeInterestStatus');?>',{"id":id,"status":20,islast:islast,orderid:"<?php echo $info['id'] ?>"},function(result){
          Msg.hide();
          $("#set_user_id_"+id).html("<?php echo $lxStatusArray[20];?>");
          $(obj).hide();
        },'json');
      },
      cancel: function() {
          $.post('<?php echo U('order/changeInterestStatus');?>',{"id":id,"status":15},function(result){
            Msg.hide();
            $("#set_user_id_"+id).html("<?php echo $lxStatusArray[15];?>");
          },'json');
      }
    });
}
</script>
<?php include getTpl('footer', 'public'); ?>